package com.team9.fitness.mapper;

import com.team9.fitness.entity.Diet;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DietMapper {

    @Insert("insert into diet(belongTo,name,weight,calories)  values(#{id},#{name},#{weight},#{calories})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void save(Long id, List<Diet> diets);

    void getAll();

    @Select("select distinct belongTo from diet order by belongTo asc")
    List<Long> getBelongs();

    @Select("select  * from diet where belongTo =#{belong}")
    List<Diet> getByBelong(Long belong);
}
